﻿using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
using System;
using System.Threading.Tasks;
using VisionCloud.Domain.Common;
using VisionCloud.Domain.DtoModel.Sys;
using VisionCloud.Domain.Filters;
using VisionCloud.Service.Sys;

namespace VisionCloud.Api.Controllers.Sys
{
    [SystemModule("消息提醒功能控制器")]
    [ApiAuthorize(PolicyEnum.RequireRolePermission)]
    [ApiVersion("1.0")]
    [Route("api/sys/[controller]/[Action]")]
    [ApiExplorerSettings(GroupName = "消息提醒功能控制器")]
    public class NotificationController : ApiBaseController
    {
        public NotificationService NotificationService { get; set; }

        /// <summary>
        /// 获取通知消息内容
        /// </summary>
        /// <param name="isPrivate">是否是私有的，默认为否</param>
        /// <returns></returns>
        [HttpGet]
        [SwaggerResponse(statusCode: 0, type: typeof(SysNotificationDto))]
        public async Task<ApiResult> GetNotification(bool isPrivate = false)
        {
            return await TryCatchAsync(NotificationService.GetNotification(TokenModel.YunUserGuid, isPrivate));
        }

        /// <summary>
        /// 设置已读
        /// </summary>
        /// <param name="UpdateNotificationId">更新通知消息Id</param>
        /// <returns></returns>
        [HttpGet]
        [SwaggerResponse(statusCode: 0, type: typeof(bool))]
        public async Task<ApiResult> SetReaded(Guid UpdateNotificationId)
        {
            return await TryCatchAsync(NotificationService.SetReaded(UpdateNotificationId, TokenModel.YunUserGuid));

        }
    }

}
